<div class="bjui-row col-2">
    <label class="row-label">标题</label>
    <div class="row-input required">
        <input type="text" name="title" id="newsinfo-title" data-rule="required">
    </div>
    <label class="row-label">内容</label>
    <div class="row-input required">
        <input type="text" name="content" id="newsinfo-content" data-rule="required">
    </div>
    <input type="hidden" id="newsinfo-getid" value="${id}">
    <input type="hidden" id="newsinfo-id">
</div>
<div class="bjui-pageFooter">
    <ul>
        <li>
            <button type="button" class="btn-close" data-icon="close">取消</button>
        </li>
        <li>
            <button onclick="return commit()" class="btn-default" id="freshNewsList" data-icon="save">保存</button>
        </li>
    </ul>
</div>
<script>
    $(function () {
        var id = $("#newsinfo-getid").val();
        if (id != "") {
            $.ajax({
                type: "POST",
                url: "/sysmanage/newsinfo/getRole.do",
                data: {'id': id},
                cache: true,
                dataType: 'JSON',
                success: function (data) {
                    bindModule(data);
                }
            })
        }
        $("#freshNewsList").click(function () {
            BJUI.navtab('refresh', 'sysnews');
        })

    });

    function commit() {
        var id = $("#newsinfo-id").val();
        var title = $("#newsinfo-title").val();
        var content = $("#newsinfo-content").val();
        var module = new Object();
        module.id = id;
        module.title = title;
        module.content = content;
        console.log(module);
        console.log(JSON.stringify(module));
        $.ajax({
            type: "POST",
            url: "/sysmanage/newsinfo/edit.do?",
            //{"id":"1","name":"管理员","createdate":"1503642104000","memo":"管理员"}
            data: JSON.stringify(module),
            dataType: 'json',
            cache: true,
            contentType: "application/json;charset=UTF-8",
            success: function (data) {
                if (data.Message === "ok") {
                    BJUI.alertmsg('ok', data.content)
                }
            }
        })
    }

    function bindModule(data) {
        $("#newsinfo-id").val(data.id);
        $("#newsinfo-title").val(data.title);
        $("#newsinfo-content").val(data.content);
    }

</script>